package com.fyy.im.server.handler;

import com.fyy.im.message.GMRequestMessage;
import com.fyy.im.message.GMResponseMessage;
import com.fyy.im.server.session.GroupSessionFactory;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.util.Set;

/**
 * @Author fyy
 * @Description
 * @Date 2021/5/12 15:26
 */
@ChannelHandler.Sharable
public class GroupMembersRequestMessageHandler extends SimpleChannelInboundHandler<GMRequestMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, GMRequestMessage msg) throws Exception {
        Set<String> members = GroupSessionFactory.getGroupSession()
                .getMembers(msg.getGroupName());
        ctx.writeAndFlush(new GMResponseMessage(members));
    }
}

